package com.dai.zhenfujin.issue.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dai.zhenfujin.Constants.Constants;
import com.dai.zhenfujin.R;
import com.dai.zhenfujin.base.BaseActivity;
import com.dai.zhenfujin.bean.UserBean;
import com.dai.zhenfujin.my.activity.AlumTypeActivity;
import com.dai.zhenfujin.my.activity.MyActivity;
import com.dai.zhenfujin.my.activity.ReleaseActivity;
import com.dai.zhenfujin.utils.SPUtils;
import com.dai.zhenfujin.utils.UIUtils;

public class AlumCardActivity extends BaseActivity implements View.OnClickListener {

    private View view;
    private ImageView imageView, ivReturn;
    private TextView tvTitleName;
    private TextView issue_major, issue_by_work,issue_history,tv_minqin;
    private String userId;
    private UserBean userBean;
    public static AlumCardActivity context;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_issue);
        context = AlumCardActivity.this;
        initView();
        initData();
    }



    private void initView() {
        userBean = (UserBean) getIntent().getSerializableExtra("userBean");
        issue_major = findViewById(R.id.issue_major);   //主业
        issue_by_work = findViewById(R.id.issue_by_work); //副业
        issue_history = findViewById(R.id.issue_history); //副业
        tv_minqin = findViewById(R.id.tv_minqin);
        imageView = findViewById(R.id.title_imageview);
        tvTitleName = findViewById(R.id.title_textview);
    }

    private void initData() {
        userId = SPUtils.getString(this, Constants.USER_MOBILE);
        tvTitleName.setText("发布产品和服务");
        imageView.setOnClickListener(this);
        issue_major.setOnClickListener(this);
        issue_by_work.setOnClickListener(this);
        issue_history.setOnClickListener(this);
        tv_minqin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.issue_major://主业
                if (TextUtils.isEmpty(SPUtils.getConversionUserJob(this, userId))) {
                    startActivity(new Intent(this, ReleaseActivity.class));
                    UIUtils.showToastSafe("请先完善名片信息");
                    return;
                }
                Intent room = new Intent(this, AlumIssueActivity2.class);
                room.putExtra("type", 3);
                startActivity(room);
                break;
            case R.id.issue_by_work://副
                if (TextUtils.isEmpty(SPUtils.getConversionUserJob(this, userId))) {
                    //  getUserInfo();
                    startActivity(new Intent(this, ReleaseActivity.class));
                    UIUtils.showToastSafe("请先完善名片信息");
                    return;
                }
                Intent vehicle = new Intent(this, AlumTypeActivity.class);
                vehicle.putExtra("type", 2);
                startActivity(vehicle);
                break;
            case R.id.issue_history://历史记录
                Intent intent = new Intent(this, MyActivity.class);
                startActivity(intent);
                break;
            case R.id.title_imageview://
                 finish();
                break;
            case R.id.tv_minqin://名片
                Intent intent2 = new Intent(this, ReleaseActivity.class);
                intent2.putExtra("userBean",userBean);
                startActivity(intent2);
                break;
        }
    }
}
